/**
 * @Description:
 * @Author bianpengfei
 * @create 2021/6/25 16:58
 */
import React, { Component } from 'react'

class Index extends Component {
  render() {
    return (
      <div>
        <h2>我是parent组件</h2>
        <Child></Child>
      </div>
    )
  }
}

class Child extends Component {
  state = {
    users: [
      { id: 1, name: '刘德华' },
      { id: 2, name: '黎明' },
      { id: 3, name: '郭富城' },
      { id: 4, name: '张学友' }
    ]
  }

  componentDidMount() {
    this.setState({
      users: null
    })
  }

  render() {
    return (
      <div>
        <h2>我是child组件</h2>
        {this.state.users.map((v, vi) => {
          return <h3 key={vi}>{v.name}</h3>
        })}
      </div>
    )
  }
}

export default Index
